package org.rency.crawler.domain;

import org.rency.common.utils.domain.BaseResult;
import org.rency.crawler.common.enums.ReturnCode;

/**
 * 描述: ${TODO}<br>
 * 最近修改时间:2017/11/22 11:21<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/22 11:21
 */
public class FetchResponse extends BaseResult {

  public static FetchResponse success(){
    return FetchResponse.success(ReturnCode.SUCCESS);
  }

  public static FetchResponse success(ReturnCode response){
    FetchResponse result = new FetchResponse();
    result.setSuccess(true);
    result.setReturnMessage(response.getMsg());
    result.setReturnCode(response.getCode());
    return result;
  }

  public static FetchResponse fail(ReturnCode response){
    FetchResponse result = new FetchResponse();
    result.setSuccess(false);
    result.setReturnMessage(response.getMsg());
    result.setReturnCode(response.getCode());
    return result;
  }

  public static FetchResponse fail(ReturnCode response,String returnMessage){
    FetchResponse result = new FetchResponse();
    result.setSuccess(false);
    result.setReturnCode(response.getCode());
    result.setReturnMessage(String.format(response.getMsg()+"[%s]",returnMessage));
    return result;
  }

}
